package com.ssyt.yt1.day14;

import java.math.BigDecimal;
import java.math.RoundingMode;

/**
 * 精确的小数运算
 * 
 * @author Administrator
 *
 */
public class BigDecimalDemo {

	// enum SoftWare {
	// RED, GREEN, BLUE;
	// }
	//
	// public static final String RED = "RED";
	// public static final String GREEN = "GREEN";
	// public static final String BLUE = "BLUE";

	public static void main(String[] args) {
		// double number1 = 2.0;
		// double number2 = 1.1;
		// System.out.println(number1 - number2);

		BigDecimal number1 = new BigDecimal("2.0");
		BigDecimal number2 = new BigDecimal("1.1");
		System.out.println(number1.add(number2));
		System.out.println(number1.subtract(number2));
		System.out.println(number1.multiply(number2));
		System.out.println(number1.divide(number2, 2, RoundingMode.HALF_EVEN));
	}
}
